package com.igeek.boot3_web_request.boot.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestAttribute;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;

/**
 * @Author: zhiyu
 * @Date:10:12
 * @DESC:
 */
@Controller
public class RfControllet {
    @GetMapping("/forwardSetData")
    public String sendData(HttpServletRequest request,Model model){
        request.setAttribute("a","aaa");
        model.addAttribute("b","bbb");
        model.addAttribute("c","ccc");
        return "forward:/forwardGetData";
    }
    @GetMapping("/forwardGetData")
    @ResponseBody
    public Map<String,Object> getData(@RequestAttribute("request-a") String a, @RequestAttribute("model-b") String b, @RequestAttribute("model-c")String c){
        HashMap<String, Object> map = new HashMap<>();
        map.put("a",a);
        map.put("b",b);
        map.put("c",c);
        return map;
    }
}
